from enum import Enum
from typing import List
from dataclasses import dataclass



class AutorType(Enum):
    SC = 'soundcloud'

@dataclass
class Author:
    id: int
    username: str
    info: str
    url: str
    type: AutorType


class Authors:
    def __init__(self) -> None:
        self.authors = []

    def add_author(self, name: str, info: str, url: str) -> int:
        author_id = len(self.authors)+1
        self.authors.append(
                 Author(
                     id=author_id,
                     username=name,
                     info=info,
                     url=url,
                     type=AutorType.SC))
        return author_id

    def get_all(self) -> List[Author]:
        return self.authors


    def get_user_by_name(self, name: str) -> Author:
        for a in self.authors:
            if a.username == name:
                return a
        return Author(666, 'Unknown user', '', '', AutorType.SC)
    

    def get_user_by_id(self, author_id: int) -> Author:
        for a in self.authors:
            if a.id == author_id:
                return a
        return Author(666, 'Unknown user', '', '', AutorType.SC)
